// 计算1-x+x^2/2!+x^3/3!
#include "stdio.h"
#include "math.h"

double getSum(double x,int n){
    long divisor = 1;
    double sum = 1;
    for (int i=1; i<=n; i++) {
        divisor = divisor*i*-1;
        // pow报错
        sum += pow(x, i) / divisor;
    }
    printf("%lf\n",sum);
    return 0;
}

int main(){
    int n = 9;
    // int *nums = (int *)malloc(sizeof(int)*(n+1));
    getSum(5, n);
    return 0;
}